package com.entity;

import java.io.Serializable;
import javax.persistence.*;

import com.alibaba.fastjson.annotation.JSONField;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;


/**
 * The persistent class for the PRODUCT_STANDARD database table.
 * 
 */
@Entity
@Table(name="PRODUCT_STANDARD")
@NamedQuery(name="ProductStandard.findAll", query="SELECT p FROM ProductStandard p")
public class ProductStandard implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="PRODUCT_STANDARD_STANID_GENERATOR", sequenceName="SEQ",initialValue=1,allocationSize=1)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="PRODUCT_STANDARD_STANID_GENERATOR")
	private long stanid;

	private String batch;

	private String code;

	private BigDecimal conversion;

	@Temporal(TemporalType.DATE)
	@Column(name="EXPIRY_DATE")
	private Date expiryDate;

	private String factory;

	@Column(name="LICENSE_NUM")
	private String licenseNum;

	private String name;

	private String outline;

	private BigDecimal price;

	@Column(name="\"Pricestrategy _id\"")
	private BigDecimal pricestrategy__id;

	@Temporal(TemporalType.DATE)
	@Column(name="RELEASE_DATE")
	private Date releaseDate;
	
	private Boolean status;

	@Column(name="UNIT_ID")
	private BigDecimal unitId;

	private BigDecimal weight;

	//bi-directional many-to-one association to Product
	@ManyToOne
	@JoinColumn(name="ID")
	private Product product;

	//bi-directional many-to-one association to Storage
	@OneToMany(mappedBy="productStandard",fetch=FetchType.EAGER)
	private List<Storage> storages;
	
	@ManyToMany
	@JSONField(serialize=false)
	@JoinTable(
		name="PS_IMAGE"
		, joinColumns={
			@JoinColumn(name="stanid")
			}
		, inverseJoinColumns={
			@JoinColumn(name="imgno")
			}
		)
	private List<Image> images;

	public ProductStandard() {
	}

	public long getStanid() {
		return this.stanid;
	}

	public void setStanid(long stanid) {
		this.stanid = stanid;
	}

	public String getBatch() {
		return this.batch;
	}

	public void setBatch(String batch) {
		this.batch = batch;
	}

	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public BigDecimal getConversion() {
		return this.conversion;
	}

	public void setConversion(BigDecimal conversion) {
		this.conversion = conversion;
	}

	public Date getExpiryDate() {
		return this.expiryDate;
	}

	public void setExpiryDate(Date expiryDate) {
		this.expiryDate = expiryDate;
	}

	public String getFactory() {
		return this.factory;
	}

	public void setFactory(String factory) {
		this.factory = factory;
	}

	public String getLicenseNum() {
		return this.licenseNum;
	}

	public void setLicenseNum(String licenseNum) {
		this.licenseNum = licenseNum;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getOutline() {
		return this.outline;
	}

	public void setOutline(String outline) {
		this.outline = outline;
	}

	public BigDecimal getPrice() {
		return this.price;
	}

	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	public BigDecimal getPricestrategy__id() {
		return this.pricestrategy__id;
	}

	public void setPricestrategy__id(BigDecimal pricestrategy__id) {
		this.pricestrategy__id = pricestrategy__id;
	}

	public Date getReleaseDate() {
		return this.releaseDate;
	}

	public void setReleaseDate(Date releaseDate) {
		this.releaseDate = releaseDate;
	}
	
	public Boolean getStatus() {
		return this.status;
	}

	public void setStatus(Boolean status) {
		this.status = status;
	}

	public BigDecimal getUnitId() {
		return this.unitId;
	}

	public void setUnitId(BigDecimal unitId) {
		this.unitId = unitId;
	}

	public BigDecimal getWeight() {
		return this.weight;
	}

	public void setWeight(BigDecimal weight) {
		this.weight = weight;
	}

	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public List<Storage> getStorages() {
		return this.storages;
	}

	public void setStorages(List<Storage> storages) {
		this.storages = storages;
	}

	public Storage addStorage(Storage storage) {
		getStorages().add(storage);
		storage.setProductStandard(this);

		return storage;
	}

	public Storage removeStorage(Storage storage) {
		getStorages().remove(storage);
		storage.setProductStandard(null);

		return storage;
	}

	public List<Image> getImages() {
		return images;
	}

	public void setImages(List<Image> images) {
		this.images = images;
	}

}